package com.sunwayhorizo.health.hl7.rim;

import com.sunwayhorizo.health.hl7.common.*;
import com.sunwayhorizo.health.hl7.datatypes.*;
import com.sunwayhorizo.health.hl7.factories.*;
import com.sunwayhorizo.health.hl7.persistent.*;
import java.io.Serializable;
import javax.persistence.*;
import static com.sunwayhorizo.health.hl7.vocabulary.RoleCdSetCode.*;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("ACSS")
public class Access extends Role implements Serializable
{
    protected static final long serialVersionUID = 1L;


    /*
     * public CE approachSiteCode; public PQ gaugeQuantity; public CE
     * targetSiteCode;
     */
    public Access()
    {
    }


    public Access(ReferenceModifier referencemodifier)
    {
        super(referencemodifier);
    }


    public void setApproachSiteCode(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreRoleCdSets(ce, APPROACHSITECODE);
        }
        else
        {
            this.setAcApproachSiteCodeEtsId(ce.code().toString());
        }
    }


    public CE getApproachSiteCode() throws Hl7Exception
    {
        if (this.getAcApproachSiteCodeEtsId().equals(APPROACHSITECODE.toString()))
        {
            for (RimCoreRoleCdSets roleCdSets : this.getRoleCdSetsList())
            {
                if (this.getAcApproachSiteCodeEtsId().equals(roleCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(roleCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getAcApproachSiteCodeEtsId());
        return null;
    }


    public void setGaugeQuantity(PQ gaugeQuantity)
    {
        this.setAcGaugeQtyTxt(gaugeQuantity.value().toString());
        this.setAcGaugeQtyUomCode(gaugeQuantity.unit().code().toString());
    }


    public PQ getGaugeQuantity() throws Hl7Exception
    {
        return DataTypeUtil.getPQ(this.getAcGaugeQtyTxt(), this.getAcGaugeQtyUomCode());
    }


    public void setTargetSiteCode(CE ce)
    {
        if (null != ce && ce.codeSystemEnName() != null && ce.codeName() != null)
        {
            this.setRimCoreRoleCdSets(ce, TARGETSITECODE);
        }
        else
        {
            this.setAcTargetSiteCodeEtsId(ce.code().toString());
        }
    }


    public CD getTargetSiteCode() throws Hl7Exception
    {
        if (this.getAcTargetSiteCodeEtsId().equals(TARGETSITECODE.toString()))
        {
            for (RimCoreRoleCdSets roleCdSets : this.getRoleCdSetsList())
            {
                if (this.getAcTargetSiteCodeEtsId().equals(roleCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(roleCdSets);
                }
            }
        }
        else
            return DataTypeUtil.getCE(this.getAcTargetSiteCodeEtsId());
        return null;
    }

    // Access
    @Column(name = "AC_APPROACH_SITE_CODE_ETS_ID")
    protected String acApproachSiteCodeEtsId = APPROACHSITECODE.toString();
    @Column(name = "AC_GAUGE_QTY_TXT")
    protected String acGaugeQtyTxt;
    @Column(name = "AC_GAUGE_QTY_UOM_CODE")
    protected String acGaugeQtyUomCode;
    @Column(name = "AC_TARGET_SITE_CODE_ETS_ID")
    protected String acTargetSiteCodeEtsId = TARGETSITECODE.toString();


    protected String getAcApproachSiteCodeEtsId()
    {
        return acApproachSiteCodeEtsId;
    }


    protected void setAcApproachSiteCodeEtsId(String acApproachSiteCodeEtsId)
    {
        this.acApproachSiteCodeEtsId = acApproachSiteCodeEtsId;
    }


    protected String getAcGaugeQtyTxt()
    {
        return acGaugeQtyTxt;
    }


    protected void setAcGaugeQtyTxt(String acGaugeQtyTxt)
    {
        this.acGaugeQtyTxt = acGaugeQtyTxt;
    }


    protected String getAcGaugeQtyUomCode()
    {
        return acGaugeQtyUomCode;
    }


    protected void setAcGaugeQtyUomCode(String acGaugeQtyUomCode)
    {
        this.acGaugeQtyUomCode = acGaugeQtyUomCode;
    }


    protected String getAcTargetSiteCodeEtsId()
    {
        return acTargetSiteCodeEtsId;
    }


    protected void setAcTargetSiteCodeEtsId(String acTargetSiteCodeEtsId)
    {
        this.acTargetSiteCodeEtsId = acTargetSiteCodeEtsId;
    }

}
